package top.cardone.context.i18n;

import java.util.Locale;

/**
 * 时区工具类
 *
 * @author yao hai tao
 */
public class LocaleContextHolder {
	/**
	 * 默认时区
	 */
	@lombok.Setter
	private static Locale defaultLocale = Locale.SIMPLIFIED_CHINESE;

	private LocaleContextHolder() {
	}

	/**
	 * 获取时区
	 *
	 * @return 时区
	 */
	public static Locale getLocale() {
		Locale locale = org.springframework.context.i18n.LocaleContextHolder.getLocale();

		if (locale != null) {
			return locale;
		}

		return defaultLocale;
	}

	/**
	 * 设置默认时区
	 */
	public static void setDefaultLocale() {
		org.springframework.context.i18n.LocaleContextHolder.setLocale(defaultLocale);
	}
}
